<template>
<div style="width: 70%">
    <div style="margin-bottom: 30px">编辑分类</div>
    <el-form :inline="true" :model="form" label-width="120px">
        <el-form-item label="名称" prop="name" >
            <el-input v-model="form.name" placeholder="请输入名称"></el-input>
        </el-form-item>
        <el-form-item label="备注"  prop="remark">
            <el-input v-model="form.remark" placeholder="请输入备注"></el-input>
        </el-form-item>
    </el-form>
    <div style="text-align: center  ;margin-top:5px ">
        <el-button type="primary" @click="update" size="medium">提交</el-button>
        <el-button type="info" @click="$router.push('/CategoryList')" size="medium">返回</el-button>
    </div>
</div>
</template>

<script>
    import request from "@/util/request";
    export default {
        name: "EditCategory",
        data(){
            return{
                form:{}
            }
        },
        created() {
            const id=this.$route.query.id
            request.get("/category/"+id).then(res=>{
                this.form=res.data
            })
        },
        methods:{
           update(){
               request.put("/category/update",this.form).then(res=>{
                   if (res.code=="200"){
                       this.$notify.success("修改成功")
                       this.$router.push("/CategoryList")
                   }else{
                       this.$notify.error(res.msg)
                   }
               })
           }
        }
    }
</script>

